@extends('frontend.layout')

@section('title')
    <title>{{ $tag->title or config('blog.title') }}</title>
@stop

@section('content')
    {{--<p>{{ $count }}</p>--}}
    @inject('metrics', 'App\Services\MetricsService')
    <div>
        {{--Monthly Revenue: {{ $metrics->monthlyRevenue() }}.--}}
    </div>
    {{--<p>{{ time() }}</p>--}}
    {{--@datetime('1517972550')--}}
    <div class="container main container-auto">
        <aside id="sidebar" class="sidebar c-overflow">
            <a id="portrait" href="{{ url('/') }}">
                <img src="{{asset('images/portrait.jpg')}}">
            </a>
            <ul class="main-menu main-ul">
                <li class="first"><a href="{{ url('/') }}" style=""><i class="zmdi zmdi-home"></i> 首页</a></li>
                @foreach ($sorts as $s)
                    <li @if (isset($sort->id) && $s->id == $sort->id) class='on-the-button' @else class='off-the-button' @endif><a href="{{ url('/blog?sort_id='.$s->id) }}"><i class="zmdi zmdi-collection-bookmark"></i> {{ $s->name }} <span class="label label-default label-totals">{{ $s->posts()->where('is_draft', 0)->count() }}</span></a></li>
                @endforeach
            </ul>
        </aside>

        <div class="row">
            <div class="col-lg-auto col-md-10">
                @if ($posts->count()=='0')
                <p class="tag-subtitle">此分类下暂无文章</p>
                @else
                    @if (isset($tag->title))
                        {{--<p class="tag-link">Explore <a href="#">{{ $tag->title or '' }}</a></p>
                        <p class="tag-subtitle">- {{ $tag->subtitle }} -</p>--}}
                    @endif
                    {{-- The Posts --}}
                    @foreach ($posts as $post)
                        <div class="post-preview">
                            <h2 class="post-title">
                                <a href="{{ $post->url($tag, $sort) }}">{{ $post->title }}</a>
                            </h2>
                            <p class="post-meta">
                                {{ $post->published_at->diffForHumans() }}
                                @unless ($post->tags->isEmpty())
                                    在 {!! implode(', ', $post->tagLinks()) !!}
                                @endunless
                            </p>
                            <p id="postSubtitle">
                                {{ $post->subtitle }}
                            </p>
                        </div>
                        <hr>
                    @endforeach
                    {{-- The Pager --}}
                    <ul class="pager">
                        {{-- Reverse direction --}}
                        @if ($reverse_direction)
                            @if ($posts->currentPage() > 1)
                                <li class="previous">
                                    <a href="{!! $posts->url($posts->currentPage() - 1) !!}">
                                        <i class="fa fa-angle-left fa-lg"></i>
                                        Previous {{ $tag->tag }}
                                    </a>
                                </li>
                            @endif
                            @if ($posts->hasMorePages())
                                <li class="next">
                                    <a href="{!! $posts->nextPageUrl() !!}">
                                        Next {{ $tag->tag }}
                                        <i class="fa fa-angle-right"></i>
                                    </a>
                                </li>
                            @endif
                        @else
                            @if ($posts->currentPage() > 1)
                                <li class="previous">
                                    <a href="{!! $posts->url($posts->currentPage() - 1) !!}">
                                        <i class="fa fa-angle-left fa-lg"></i>
                                        Newer {{ $tag ? $tag->tag : '' }}
                                    </a>
                                </li>
                            @endif
                            @if ($posts->hasMorePages())
                                <li class="next">
                                    <a href="{!! $posts->nextPageUrl() !!}">
                                        Older {{ $tag ? $tag->tag : '' }}
                                        <i class="fa fa-angle-right"></i>
                                    </a>
                                </li>
                            @endif
                        @endif
                    </ul>
                @endif
            </div>
        </div>
    </div>
@stop